const {
  observable,
  transaction,
  autorun,
  runInAction,
  action,
  toJS,
} = require("mobx");

let numbers = observable.box(0);

autorun(() => console.log(toJS(numbers.get()), "numbers!"));
// Prints: '0 numbers!'

// 推荐使用action和runInAction的原因就是原子性
action(() => {
  numbers.set(numbers.get() + 42);
  numbers.set(numbers.get() + 42);
  numbers.set(numbers.get() + 42);
  numbers.set(numbers.get() + 42);
  numbers.set(numbers.get() + 42);
})();
